//1、规定各种数据类型
// 规则定义：required:邮箱或者密码不能为空；email:符合email的格式；password:包含字母和数字；range:密码的长度范围
interface RuleProp {
    type:'required' | 'email' | 'password' | 'range' | 'custom'
    message: string
    min?:number
    max?:number
    validator?:() => boolean
}
//图像类型的定义
interface ImageProps{
  _id?:string,
  url?:string,
  createdAt?:string
}
//专栏列表类型定义
interface ColumnProps {
    _id: string;
    title: string;
    avatar?: ImageProps;
    description: string;
  }
//专栏详情类型定义
interface PostProps {
    _id?: string;
    title: string;
    excerpt?:string;
    content?: string;
    image?:ImageProps | string;
    createdAt?: string;
    column: string;
    author?:string;
  }
//用户类型定义
interface UserProps{
    isLogin:boolean,
    nickName?:string,
    _id?:string,
    column?:string,
    email?:string,
}
//所有数据的类型定义
interface GlobalDataProps{
    error:GlobalErrorsProps,
    loading:boolean,
    columns:ColumnProps[],
    posts:PostProps[],
    user:UserProps,
    token:string,
    article:ArtilceProps
}
interface GlobalErrorsProps{
  status:boolean,
  message?:string,
}
interface ResponseType<P = {}>{
  code:number,
  msg:string,
  data:P
}
//文章的类型定义
interface ArtilceProps{
  _id?:string,
  title?:string,
  excerpt?:string,
  content?:string,
  image?:ImageProps | string,
  author?:Author,
  column?:string,
  createdAt?:string,
}
interface Author{
  _id:string,
  email:string,
  nickName:string,
  description:string,
  avatar:string,
  column:string,
  createdAt:string,
}
//2、导出的数据的格式
export type RulesProp = RuleProp[]
export type {
  ColumnProps,
  PostProps,
  UserProps,
  GlobalDataProps,
  GlobalErrorsProps,
  ResponseType,
  ImageProps,
}
